//
//  MVAllKindsClassifyCollectionViewCell.m
//  NewMusic
//
//  Created by dllo on 15/11/21.
//  Copyright © 2015年 Going. All rights reserved.
//

#import "MVAllKindsClassifyCollectionViewCell.h"

@interface MVAllKindsClassifyCollectionViewCell ()
@property(nonatomic, retain) UIView *backView;
@property(nonatomic, retain) UILabel *titileLabel;
@end

@implementation MVAllKindsClassifyCollectionViewCell
- (void)dealloc {
    [_typeModel release];
    [_nameString release];
    [_backView release];
    [_titileLabel release];
    [super dealloc];
}
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        //创建视图
        [self createSubView];
    }
    return self;
}
#pragma mark 创建视图
- (void)createSubView {
    //背景图片
    self.backView = [[UIView alloc]init];
    _backView.backgroundColor = [UIColor whiteColor];
    _backView.alpha = 0.3;
    [self.contentView addSubview:_backView];
    [_backView release];
    //标题
    self.titileLabel = [[UILabel alloc]init];
//    _titileLabel.backgroundColor = [UIColor cyanColor];
    _titileLabel.textColor = [UIColor whiteColor];
    _titileLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:_titileLabel];
    [_titileLabel release];
}
#pragma mark 设置大小
-(void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    _backView.frame = CGRectMake(0, 0, self.width, self.height);
    _titileLabel.frame = CGRectMake(0, 0, self.width, self.height);
}
#pragma mark 重写typeModel的setter方法
-(void)setTypeModel:(MVTypeModel *)typeModel {
    if (_typeModel != typeModel) {
        [_typeModel release];
        _typeModel = [typeModel retain];
    }
    _titileLabel.text = typeModel.name;
}
#pragma mark 重写nameString的setter方法
-(void)setNameString:(NSString *)nameString {
    if (_nameString != nameString) {
        [_nameString release];
        _nameString = [nameString copy];
    }
    _titileLabel.text = nameString;
}
@end
